﻿Chenxin.UI.Turnover = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/Reports/Turnover.ashx',
    createSearch: function() {
        return new Chenxin.UI.TurnoverSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.GroupReportGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            height:400,
            renderTo: 'divShowBalanceList',
            hasCheckBox: false,
            scope: this,
            id: 'BalanceList',
            title: '运营成交表',
            scope: this,
			modelId:'DepartId',
			cellBorder:true,
			autoLoad:false,
            rowGroupSetting: [
				{ field: 'business', head: '商圈', width: 120, autoCount: true },
				{ field: 'departname', head: '门店', width: 120, autoCount: false }
			],
            columns: {
                M: {
                    head: 'M案',
                    items: {
                    m_count: {
                            head: '签约套数',
                            width: 80,
                            sortable: true
                        },
                        m_area: {
                            head: '签约面积',
                            width: 100,
                            sortable: true
                        },
                        m_price: {
                            head: '签约金额',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                Z: {
                    head: 'Z案',
                    items: {
                    z_count: {
                            head: '签约套数',
                            width: 80,
                            sortable: true
                        },
                        z_area: {
                            head: '签约面积',
                            width: 100,
                            sortable: true
                        },
                        z_price: {
                            head: '签约金额',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                L: {
                    head: 'L案',
                    items: {
                        l_count: {
                            head: '签约套数',
                            width: 80,
                            sortable: true
                        },
                        l_area: {
                            head: '签约面积',
                            width: 100,
                            sortable: true
                        },
                        l_price: {
                            head: '签约金额',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                Q: {
                    head: 'Q案',
                    items: {
                        q_count: {
                            head: '签约套数',
                            width: 80,
                            sortable: true
                        },
                        q_area: {
                            head: '签约面积',
                            width: 100,
                            sortable: true
                        },
                        q_price: {
                            head: '签约金额',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                LD: {
                    head: '联动',
                    items: {
                        ld_count: {
                            head: '签约套数',
                            width: 80,
                            sortable: true
                        },
                        ld_area: {
                            head: '签约面积',
                            width: 100,
                            sortable: true
                        },
                        ld_price: {
                            head: '签约金额',
                            width: 80,
                            sortable: true
                        },
                        count: {
                            head: '成销套数',
                            width: 80,
                            sortable: true
                        },
                        area: {
                            head: '成销面积',
                            width: 100,
                            sortable: true
                        },
                        price: {
                            head: '成销金额',
                            width: 80,
                            sortable: true
                        }
                    }
                }
			}
        });
    }
});

/*
* 查询面板
*/
Chenxin.UI.TurnoverSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'divCondition',
    createComboList: function() {
		
		var _this=this;
        this.combl = new Chenxin.UI.StructComboList();
        var structs = this.combl.comboList;

        return structs;
    },
    initEvent: function() {
        
		var date=new Date();
        $("#txtStartTime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        }).defText({
            deftxt: '开始时间'
        });
		$("#txtStartTime").val(date.getFullYear()+'-'+(date.getMonth()+1)+'-1');
		

        $("#txtEndTime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        }).defText({
            deftxt: '结束时间'
        });
        if (date.getMonth() + 1 == 12)
            $('#txtEndTime').val(date.getFullYear() + 1 + '-1-1');
        else
            $('#txtEndTime').val(date.getFullYear() + '-' + (date.getMonth() + 2) + '-1');

        var objSrh = this;
        /*********事件：检索按钮*********/
        $("#btSearch").click(function() {
            objSrh.scope.reloadGrid();
        });
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(function() {
    var objPg = new Chenxin.UI.Turnover();
});